var fireRate = 0.10;
var impact:GameObject;
var canFire = true;
var damage:float = 10;

var shotSound:AudioClip;
private var GamePaused = true;


function Update () {
	if(!GamePaused){
		if(Input.GetButton("Fire1"))
		{
			Fire();
		}
	}
}

function Fire()
{
	if(canFire)
    {
        canFire = false;
        FireShot();
    }
}

function FireShot()
{
	audio.PlayOneShot(shotSound);
    var direction = transform.TransformDirection(Vector3.forward);
	var hit:RaycastHit;
	
	if(Physics.Raycast(transform.position,direction,hit,100))
	{
		tempRot = Quaternion.FromToRotation(Vector3.up,hit.normal);
		Instantiate(impact,hit.point,tempRot);
		hit.collider.SendMessageUpwards("makeDamage",damage,SendMessageOptions.DontRequireReceiver);
	}
	yield WaitForSeconds(fireRate);
	
	canFire = true;
}

function TogglePause(){
	GamePaused = !GamePaused;
}